<template>
	<view class="wrap">
		<u-swiper :height="270" :list="imgList" :title="false" @click="imgListClick"></u-swiper>
		<view class="workbench-title">协同办公</view>
		<view class="toolbar">
			<u-grid class="grid" :col="3" :border="false">
				<u-grid-item :index="0" @click="navTo('/pages/oa/form')" v-if="$checkPermission('pages_oa_form')">
					<u-icon class="grid-icon" name="plus-circle" :size="80" :style="{ color: '#5a98ea' }"></u-icon>
					<view class="grid-text">发起任务</view>
				</u-grid-item>
				<u-grid-item :index="1" @click="navTo('/pages/oa/todos')" v-if="$checkPermission('pages_oa_todos')">
					<u-badge :count="todoCount" v-if="todoCount != 0"></u-badge>
					<u-icon class="grid-icon" name="clock" :size="80" :style="{ color: '#ea9a44' }"></u-icon>
					<view class="grid-text">待办任务</view>
				</u-grid-item>
				<u-grid-item :index="2" @click="navTo('/pages/oa/history')" v-if="$checkPermission('pages_oa_history')">
					<u-icon class="grid-icon" name="calendar" :size="80" :style="{ color: '#47cb66' }"></u-icon>
					<view class="grid-text">请假列表</view>
				</u-grid-item>
			</u-grid>
		</view>
		<view class="workbench-title">常用功能</view>
		<view class="toolbar">
			<u-grid class="grid" :col="3" :border="false">
				<u-grid-item :index="0" @click="navTo('/pages/sys/unixUser/index')"
					v-if="$checkPermission('pages_sys_unixUser')">
					<view class="home-icon icon-color01">
						<i class="iconfont icon-people"></i>
					</view>
					<view class="grid-text">用户管理</view>
				</u-grid-item>
				<u-grid-item :index="1" @click="navTo('/pages/sys/token/index')" v-if="$checkPermission('pages_sys_token')">
					<view class="home-icon icon-color02">
						<i class="iconfont icon-key"></i>
					</view>
					<view class="grid-text">令牌管理</view>
				</u-grid-item>
				<u-grid-item :index="2" @click="navTo('/pages/sys/unixRole/index')"
					v-if="$checkPermission('pages_sys_unixRole')">
					<view class="home-icon icon-color03">
						<i class="iconfont icon-log"></i>
					</view>
					<view class="grid-text">角色管理</view>
				</u-grid-item>
			</u-grid>
			<u-grid class="grid" :col="3" :border="false">
				<u-grid-item :index="0" @click="navTo('/pages/sys/unixPost/index')"
					v-if="$checkPermission('pages_sys_unixPost')">
					<view class="home-icon icon-color04">
						<i class="iconfont icon-transporter"></i>
					</view>
					<view class="grid-text">岗位管理</view>
				</u-grid-item>
				<u-grid-item :index="1" @click="navTo('/pages/sys/unixTenant/index')"
					v-if="$checkPermission('pages_sys_unixTenant')">
					<view class="home-icon icon-color05">
						<i class="iconfont icon-faan"></i>
					</view>
					<view class="grid-text">租户管理</view>
				</u-grid-item>
				<u-grid-item :index="2" @click="navTo('/pages/sys/unixParam/index')"
					v-if="$checkPermission('pages_sys_unixParam')">
					<view class="home-icon icon-color06">
						<i class="iconfont icon-shezhi_setting"></i>
					</view>
					<view class="grid-text">参数管理</view>
				</u-grid-item>
			</u-grid>
		</view>
	</view>
</template>
<script>
export default {
	data() {
		return {
			imgList: [{
				image: '/static/custom/banner/1.svg'
			},
			{
				image: '/static/custom/banner/2.svg'
			},
			{
				image: '/static/custom/banner/3.svg'
			}
			],
			query: {
				current: 1,
				size: 20
			},
			todoCount: 0
		};
	},
	onShow() {
		// this.refreshCount();
	},
	methods: {
		navTo(url) {
			uni.navigateTo({
				url: url
			});
		},
		refreshCount() {
			this.$u.api.unixOA.queryTodos(this.query).then(res => {
				if (!res.data.records || res.data.records.length == 0) {
					return;
				}
				this.todoCount = res.data.total;
			});
		},
		imgListClick(index) {
		},
		itemClick(index) {
		}
	}
};
</script>
<style lang="scss">
@import 'index.scss';
</style>
